exports.__esModule = true;

function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }

exports.default = class extends think.BaseController {

    /**
     * 单元网格立案数
     */
    getBGIDCaseAction() {
        var _this = this;

        return _asyncToGenerator(function* () {
            let aj = think.ajaxJson();
            const AreaService = _this.service('overallmerit/AreaService');
            const data = {
                cycle: Number(_this.get('cycle')),
                rangeDate: _this.get('rangeDate'),
                BGID: _this.get('BGID[]')
            };
            const res = yield AreaService.getBGIDCase(data);
            if (res && res.error) {
                aj.success = false;
                aj.msg = '查询失败';
            } else {
                aj.result = res;
            }
            return _this.json(aj);
        })();
    }
    /**
     * 条件统计查询区域立案数
     * 
     * @returns 
     */
    queryAllAreaDataAction() {
        var _this2 = this;

        return _asyncToGenerator(function* () {
            let aj = think.ajaxJson();
            let data = {
                level: Number(_this2.get('level')),
                cycle: Number(_this2.get('cycle')),
                rangeDate: _this2.get('rangeDate'),
                area_code: _this2.get('area_code[]'),
                BGID: _this2.get('BGID[]')
            };
            const AreaService = _this2.service('overallmerit/AreaService');
            const res = yield AreaService.getAreaData(data);
            if (!res.error) {
                aj.result = res;
            } else {
                aj.success = false;
                aj.msg = '查询失败';
            }
            return _this2.json(aj);
        })();
    }

    /**
     * 获取街道，社区
     *param    type(string) 查询的类型(street-街道，community-社区，cell-单元网格
     *param    area_coed(array) 可选 所属区域编码
     *param is_include_parent(0,1) 查询是否包含父级（0-查询不包含父级，1-查询包含父级） 默认为1
     * @returns
     */
    getStreetOrCommunityAction() {
        var _this3 = this;

        return _asyncToGenerator(function* () {
            let aj = think.ajaxJson();
            let data = {
                type: _this3.post('type'),
                area_coed: _this3.post('area_coed'),
                is_include_parent: _this3.post('is_include_parent') ? _this3.post('is_include_parent') : 1
            };
            const AreaService = _this3.service('overallmerit/AreaService');
            if (data.type === 'street') {
                const res = yield AreaService.getStreet(data);
                if (!res.error) {
                    aj.result = res;
                } else {
                    aj.success = false;
                    aj.msg = '查询失败';
                }
            } else if (data.type === 'community') {
                const res = yield AreaService.getCommunity(data);
                if (!res.error) {
                    aj.result = res;
                } else {
                    aj.success = false;
                    aj.msg = '查询失败';
                }
            } else {
                aj.success = false;
                aj.msg = '查询失败';
            }

            return _this3.json(aj);
        })();
    }
    /**
     * 获取区域单元网格树
       * @returns
     */
    getCellTreeAction() {
        var _this4 = this;

        return _asyncToGenerator(function* () {
            let aj = think.ajaxJson();
            const AreaService = _this4.service('overallmerit/AreaService');
            const res = yield AreaService.getCellTree();
            if (!res.error) {
                aj.result = res;
            } else {
                aj.success = false;
                aj.msg = '查询失败';
            }

            return _this4.json(aj);
        })();
    }
};